#
# Copyright 2024 Kumo.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# below are examples, after initialization, modify it to your own.
###########################################################################
###kmcmake_example

set(PG_SRC
        postgre/parser.cc
        postgre/functions.cc
        postgre/parser/parser.cc
        postgre/nodes/list.cc
        postgre/parser/scansup.cc
        postgre/nodes/make_funcs.cc
        postgre/nodes/value.cc
        postgre/parser/scan.cc
        postgre/common/keywords.cc
        postgre/parser/gram.cc
)

kmcmake_cc_library(
        NAMESPACE ${PROJECT_NAME}
        NAME postgre
        SOURCES
        ${PG_SRC}
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PLINKS
        ${KMCMAKE_DEPS_LINK}
        PUBLIC
)

add_custom_target(
        gen_sql_parser
        COMMAND make clean && make
        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/kmsql/sql/parser
)
file(GLOB_RECURSE SQL_SRC "sql/*.cc" "sql/*.cpp")
kmcmake_cc_library(
        NAMESPACE ${PROJECT_NAME}
        NAME sql
        SOURCES
        ${SQL_SRC}
        DEPS
        gen_sql_parser
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PLINKS
        ${KMCMAKE_DEPS_LINK}
        PUBLIC
)
###kmcmake_example